// 获取用户信息
function getUserInfo() {
    $.ajax({
        url: "/my/userinfo",
        success: function(res) {
            if (!res.data) return;
            if (res.data.user_pic === null) {
                var firstWord = (res.data.nickname || res.data.username).charAt(0).toUpperCase();
                $(".text-avatar").html(firstWord).css("visibility", "visible");
                $(".layui-nav-img").hide();
            } else {
                $(".layui-nav-img").attr("src", res.data.user_pic).show()
                $(".text-avatar").hide();
            }
            $(".welcome").html("Welcome " + (res.data.nickname || res.data.username))
        }
    })
}
getUserInfo();
//退出
$(".out").on("click", function() {

    layer.confirm('要滚蛋么？亲', {
        icon: 3,
        title: '提示'
    }, function(index) {
        location.href = "/login.html";
        localStorage.removeItem("token");

        layer.close(index);
    });
})